﻿import re, sys
from django import  template

register = template.Library()

@register.filter(name='pluralize')
def pluralize(value):
    """Polish implementation"""
    try:
        if int(value) in (12,13,14):
            return 'ów'
        elif int(value)%10 in (2,3,4):
            return 'y'
        elif int(value) >= 5 or int(value) == 0:
            return 'ów' # utf8
    except ValueError: # invalid string that's not a number
        pass
    except TypeError:
        try:
            if int(value) in (12,13,14):
                return 'ów'
            elif int(value)%10 in (2,3,4):
                return 'y'
            elif int(value) >= 5 or int(value) == 0:
                return 'ów' # utf8  
        except TypeError: 
            pass
    return ''